home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GNUGEM27 / AESEVNT.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  6KB  |  248 lines

  1. /*
  2.  *    Aes event library interface
  3.  *
  4.  *        evnt_keybd    Wait for a keyboard event
  5.  *        evnt_button Wait for a mouse button
  6.  *        evnt_mouse    Wait for a mouse to enter/leave a rectangle
  7.  *        evnt_mesag    Wait for a message from another application
  8.  *        evnt_timer    Wait for a specified amount of time
  9.  *        evnt_multi    Wait for one of many possible events
  10.  *        evnt_dclick Set or get the present double click speed
  11.  *
  12.  *        ++jrb    bammi@cadence.com
  13.  *        modified: mj -- ntomczak@vm.ucs.ualberta.ca
  14.  */
  15. #include "common.h"
  16.  
  17. #ifdef __DEF_ALL__
  18.  
  19. #define L_evnt_key
  20. #define L_evnt_but
  21. #define L_evnt_mou
  22. #define L_evnt_mes
  23. #define L_evnt_tim
  24. #define L_evnt_mul
  25. #define L_evnt_dcl
  26.  
  27. #endif /* __DEF_ALL__ */
  28.  
  29.  
  30. #ifdef L_evnt_key
  31.  
  32. /* Wait for a keyboard event
  33.  *    returns kdb code of the key hit
  34.  */
  35. int evnt_keybd(void)
  36. {
  37.     return __aes__(AES_CONTROL_ENCODE(20, 0, 1, 0));
  38. }
  39. #endif /* L_evnt_key */
  40.  
  41.  
  42. #ifdef L_evnt_but
  43.  
  44. /* wait for a mouse button state
  45.  *    Clicks        The number of times to wait for a button to enter state
  46.  *    WhichButton Which of the mouse buttonss (1 for left 2 for right)
  47.  *    WhichState    Which state are we waiting for (0 = down  1 = up)
  48.  *    Mx, My        X,Y coordinate of mouse when event occured
  49.  *    ButtonState The button state when event occured
  50.  *    KeyState    State of Shift, Ctrl and Alt keys when event occured
  51.  *
  52.  *    returns     The number of times the button actually entered
  53.  *            the desired state.
  54.  */
  55. int evnt_button(int Clicks,
  56.         int WhichButton,
  57.         int WhichState,
  58.         int *Mx, int *My,
  59.         int *ButtonState, int *KeyState)
  60. {
  61.     int retval;
  62.  
  63.     _int_in[0] = Clicks;
  64.     _int_in[1] = WhichButton;
  65.     _int_in[2] = WhichState;
  66.  
  67.     retval = __aes__(AES_CONTROL_ENCODE(21, 3, 5, 0));
  68.     *Mx = _int_out[1];
  69.     *My = _int_out[2];
  70.     *ButtonState = _int_out[3];
  71.     *KeyState     = _int_out[4];
  72.     return retval;
  73. }
  74. #endif /* L_evnt_but */
  75.  
  76.  
  77. #ifdef L_evnt_mou
  78.  
  79. /* wait for mouse event
  80.  *    EnterExit    =0 return on entry    =1 return on exit
  81.  *    InX,InY,InW,InH The rectangle to monitor entry/exit out of
  82.  *    OutX,OutY      X,Y coordinate of mouse when event occured
  83.  *    ButtonState   State of mouse buttons when event occured (1=l  2=r but)
  84.  *    KeyState      State of Shift, Ctrl and Alt keys when event occured
  85.  *
  86.  *    always returns a reserved val.
  87.  */
  88. int evnt_mouse(int EnterExit, int InX, int InY, int InW, int InH,
  89.            int *OutX, int *OutY,
  90.            int *ButtonState,
  91.            int *KeyState)
  92. {
  93.     int retval;
  94.  
  95.     _int_in[0] = EnterExit;
  96.     _int_in[1] = InX;
  97.     _int_in[2] = InY;
  98.     _int_in[3] = InW;
  99.     _int_in[4] = InH;
  100.     retval = __aes__(AES_CONTROL_ENCODE(22, 5, 5, 0));
  101.     *OutX = _int_out[1];
  102.     *OutY = _int_out[2];
  103.     *ButtonState = _int_out[3];
  104.     *KeyState     = _int_out[4];
  105.     return retval;
  106. }
  107. #endif /* L_evnt_mou */
  108.  
  109.  
  110. #ifdef L_evnt_mes
  111.  
  112. /* Wait for a 16 byte message from pipe
  113.  *    returns a reserved value
  114.  */
  115. int evnt_mesag(int MesagBuf[])
  116. {
  117. #ifndef __MSHORT__
  118. #ifdef __GNUC__
  119.     volatile
  120. #endif
  121.     short dummy[8];
  122.     register int i;
  123.     register int   retval;
  124.  
  125.     _addrin[0] = (void *)&dummy[0]; /* Address of 16 byte message buffer */
  126.     retval = __aes__(AES_CONTROL_ENCODE(23, 0, 1, 1));
  127.     if(MesagBuf != (int *)0)
  128.     for(i = 0; i < 8; i++)
  129.         MesagBuf[i] = dummy[i];
  130.     return retval;
  131. #else
  132.     _addrin[0] = MesagBuf;    /* Address of 16 byte message buffer */
  133.     return __aes__(AES_CONTROL_ENCODE(23, 0, 1, 1));
  134. #endif
  135. }
  136. #endif /* L_evnt_mes */
  137.  
  138.  
  139. #ifdef L_evnt_tim
  140.  
  141. /* sleep for Interval
  142.  *    returns a reserved value
  143.  */
  144. int evnt_timer(unsigned long Interval)
  145. {
  146.     unsigned short *i = (unsigned short *)&Interval;
  147.  
  148.     _int_in[0] = i[1];
  149.     _int_in[1] = i[0];
  150.     return __aes__(AES_CONTROL_ENCODE(24, 2, 1, 0));
  151. }
  152. #endif /* L_evnt_tim */
  153.  
  154. #ifdef L_evnt_mul
  155.  
  156. /* wait for one of many events
  157.  *    Type    The types of Events to wait for
  158.  *        rest of the parameters analogus to ones defined above.
  159.  *
  160.  *    returns The event that ended the wait
  161.  *
  162.  */
  163. int evnt_multi(int Type,
  164.            int Clicks,        /* Inputs */
  165.            int WhichButton,
  166.            int WhichState,
  167.            int EnterExit1, int In1X, int In1Y, int In1W, int In1H,
  168.            int EnterExit2, int In2X, int In2Y, int In2W, int In2H,
  169.            int MesagBuf[],
  170.            unsigned long Interval,
  171.            int *OutX, int *OutY,    /* Outputs */
  172.            int *ButtonState,
  173.            int *KeyState,
  174.            int *Key,
  175.            int *ReturnCount)
  176. {
  177.     unsigned short *i = (unsigned short *)&Interval;
  178.     int retval;
  179. #ifndef __MSHORT__
  180.     register int j;
  181. #ifdef __GNUC__
  182.     volatile
  183. #endif
  184.     short dummy[8];
  185. #endif
  186.  
  187.     _int_in[0] = Type;
  188.     _int_in[1] = Clicks;
  189.     _int_in[2] = WhichButton;
  190.     _int_in[3] = WhichState;
  191.  
  192.     _int_in[4] = EnterExit1;
  193.     _int_in[5] = In1X;
  194.     _int_in[6] = In1Y;
  195.     _int_in[7] = In1W;
  196.     _int_in[8] = In1H;
  197.  
  198.     _int_in[9] = EnterExit2;
  199.     _int_in[10] = In2X;
  200.     _int_in[11] = In2Y;
  201.     _int_in[12] = In2W;
  202.     _int_in[13] = In2H;
  203.  
  204.     _int_in[14] = i[1];
  205.     _int_in[15] = i[0];
  206.  
  207. #ifdef __MSHORT__
  208.     _addrin[0] = MesagBuf;
  209. #else
  210.     _addrin[0] = (void *)&dummy[0];
  211. #endif
  212.  
  213.     retval = __aes__(AES_CONTROL_ENCODE(25, 16, 7, 1));
  214.  
  215.     *OutX = _int_out[1];
  216.     *OutY = _int_out[2];
  217.     *ButtonState = _int_out[3];
  218.     *KeyState     = _int_out[4];
  219.     *Key     = _int_out[5];
  220.     *ReturnCount = _int_out[6];
  221.  
  222. #ifndef __MSHORT__
  223.     if(MesagBuf != (int *)0)
  224.         for(j = 0; j < 8; j++)
  225.         MesagBuf[j] = dummy[j];
  226. #endif
  227.  
  228.     return retval;
  229. }
  230. #endif /* L_evnt_mul */
  231.  
  232. #ifdef L_evnt_dcl
  233.  
  234. /*    Set/get double click speed
  235.  *    returns current setting
  236.  */
  237. int evnt_dclick(int ToSet,    /*    Speed to set at [0,4] */
  238.         int SetGet) /*    1= set    0=get          */
  239. {
  240.     _int_in[0] = ToSet;
  241.     _int_in[1] = SetGet;
  242.     return __aes__(AES_CONTROL_ENCODE(26, 2, 1, 0));
  243. }
  244. #endif /* L_evnt_dcl */
  245.  
  246.  
  247. /* - eof - */
  248.